<template>

  <div class="app-container">

    <el-form :model="queryParams" ref="queryForm" :rules="queryForm" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="企业名称" prop="compName">
        <el-input
          v-model="queryParams.compName"
          placeholder="请输入企业名称"
          clearable
          size="small"
          maxlength="30"
          show-word-limit
        />
      </el-form-item>
      <el-form-item label="缴费类型" prop="ruleType">
        <el-select v-model="queryParams.ruleType" placeholder="请选择缴费类型"
                   clearable>
          <el-option
            v-for="dict in typeOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>

      <el-form-item label="缴费时间" label-width="100">
        <el-date-picker
          v-model="dateRange"
          size="small"
          style="width: 240px"
          value-format="yyyy-MM-dd"
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        ></el-date-picker>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button type="info" icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          size="mini"
          @click="handleRule"
          v-hasPermi="['server:rule:list']"
        >缴费规则
        </el-button>
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['server:record:list']"
        >新增
        </el-button>
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['server:record:remove']"
        >删除
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['server:record:export']"
        >导出
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="info"
          plain
          icon="el-icon-upload2"
          size="mini"
          @click="handleImport"
          v-hasPermi="['server:record:import']"
        >导入
        </el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList" :columns="columns"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="payRecordList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center"/>
      <el-table-column label="序号" align="center" type="index" key="payId" prop="payId" v-if="columns[0].visible"/>
      <el-table-column label="企业名称" align="center" key="compName" prop="compName" v-if="columns[1].visible"
                       :show-overflow-tooltip="true"/>
      <el-table-column label="应缴金额" align="center" key="pay" prop="pay" v-if="columns[2].visible"
                       :show-overflow-tooltip="true"/>
      <el-table-column label="缴费时间" align="center" key="payTime" prop="payTime" v-if="columns[3].visible"
                       :show-overflow-tooltip="true"/>
      <el-table-column label="未交金额" align="center" key="unpaid" prop="unpaid" v-if="columns[4].visible"
                       :show-overflow-tooltip="true"/>
      <el-table-column label="缴费类型" align="center" key="ruleType" prop="ruleType" :formatter="typeFormat" v-if="columns[5].visible"
                       :show-overflow-tooltip="true"/>
      <el-table-column label="缴费状态" align="center" key="payStatus" prop="payStatus" :formatter="statusFormat"
                       v-if="columns[6].visible"
                       :show-overflow-tooltip="true"/>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['server:record:edit']"
          >修改
          </el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['server:record:remove']"
          >删除
          </el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改缴费记录对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="100px">
     <el-form-item label="企业名称" prop="compName">
       <el-select v-model="form.compName" placeholder="请选择" @change="selectGet" style="width: 360px;">
         <el-option
           v-for="item in compOptions"
           :key="item.compId"
           :label="item.compName"
           :value="item.compId"
           ></el-option>
       </el-select>
     </el-form-item>
        <el-form-item label="财务姓名" prop="userName">
          <el-select v-model="form.userName" style="width: 360px"
                     filterable
                     placeholder="请输入服务人员姓名"
                     remote
                     clearable
                     reserve-keyword
                     @change="changePhone"
                     :remote-method="serversClick">
            <el-option
              v-for="item in userOptions"
              :key="item.userId"
              :label="item.userName"
              :value="item.userId"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="财务电话" prop="userPhone">
          <el-input v-model="form.userPhone" placeholder="请输入服务人员电话" maxlength="20"/>
        </el-form-item>
        <el-form-item label="缴费类型" prop="ruleType">
            <el-select v-model="form.ruleType" placeholder="请选择缴费类型"  style="width: 360px;">
              <el-option
                v-for="dict in typeOptions"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              />
            </el-select>
        </el-form-item>
        <el-form-item label="应缴金额" prop="pay">
          <el-input v-model="form.pay" type="number" placeholder="请输入应缴金额" maxlength="30"/>
        </el-form-item>
        <el-form-item label="缴费时间">
          <el-date-picker
            style="width: 360px;"
            v-model="form.payTime"
            size="small"
            value-format="yyyy-MM-dd HH:mm:ss"
            type="datetime"
          ></el-date-picker>
        </el-form-item>
        <el-form-item label="缴费状态" prop="payStatus">
          <el-select v-model="form.payStatus" placeholder="请选择" style="width: 360px;">
            <el-option
              v-for="dict in statusOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="dict.dictValue"
              />
          </el-select>
        </el-form-item>
        <el-form-item label="备注" prop="remark">
          <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" maxlength="200"/>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <!--    导入缴费记录  -->
    <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" >
      <el-form-item label="缴费类型" prop="ruleType">
        <el-select v-model="form.ruleType" placeholder="请选择缴费类型"  style="width: 360px;">
          <el-option
            v-for="dict in typeOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
      </el-form>
      <el-upload
        ref="upload"
        :limit="1"
        accept=".xlsx, .xls"
        :headers="upload.headers"
        :action="upload.url + '?updateSupport=' + upload.updateSupport + '&ruleType=' + form.ruleType"
        :disabled="upload.isUploading"
        :on-progress="handleFileUploadProgress"
        :on-success="handleFileSuccess"
        :auto-upload="false"
        drag
      >
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">
          将文件拖到此处，或
          <em>点击上传</em>
        </div>
        <div class="el-upload__tip" slot="tip">
          <el-checkbox v-model="upload.updateSupport"/>
          是否更新已存在的缴费记录数据
          <el-link type="info" style="font-size:12px" @click="importTemplate">下载模板</el-link>
        </div>
        <div class="el-upload__tip" style="color:red" slot="tip">提示：仅允许导入“xls”或“xlsx”</div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFileForm">确 定</el-button>
        <el-button @click="upload.open = false">取 消</el-button>
      </div>
    </el-dialog>

    <!--    缴费规则管理对话框 -->
    <el-dialog :title="title" :visible.sync="rule" width="900px" append-to-body>
      <el-button type="primary" plain
                 icon="el-icon-plus"
                 size="mini"
                 @click="addRuleList"
                 v-hasPermi="['server:rule:add']"
      >添加规则
      </el-button>
      <el-table v-loading="loading"  :data="ruleList" @cell-click="tabClick">
        <el-table-column label="序号" type="index" align="center" prop="ruleId">
          <template slot-scope="scope">
            {{ scope.row.ruleId }}
          </template>
        </el-table-column>
        <el-table-column label="规则名称" align="center">
          <template slot-scope="scope">
            <span v-if="scope.row.ruleId === undefined">
              <el-input v-model="scope.row.ruleName" placeholder="请输入规则名称" maxlength="30"/>
            </span>
            <span v-else-if="scope.row.ruleId === tabClickIndex && tabClickLabel ==='规则名称'">
            <el-input v-model="scope.row.ruleName" placeholder="请输入规则名称" @blur="inputBlur(scope.row)" maxlength="30"/>
            </span>
            <span v-else>{{ scope.row.ruleName }}</span>
          </template>
        </el-table-column>
        <el-table-column label="缴费类型" align="center">
          <template slot-scope="scope">
            <span v-if="scope.row.ruleId === undefined">
            <el-select v-model="scope.row.ruleType" placeholder="请选择缴费类型">
              <el-option
                v-for="dict in typeOptions"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              />
            </el-select>
            </span>
            <span v-else-if="scope.row.ruleId === tabClickIndex && tabClickLabel ==='缴费类型'">
              <el-select v-model="scope.row.ruleType" placeholder="请选择" @blur="inputBlur(scope.row)">
                <el-option
                  v-for="dict in typeOptions"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="dict.dictValue"
                />
              </el-select>
            </span>
            <span v-else>
              <el-select v-model="scope.row.ruleType">
              <el-option
                v-for="dict in typeOptions"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              />
            </el-select></span>
          </template>
        </el-table-column>
        <el-table-column label="缴费时间" align="center">
          <template slot-scope="scope">
            <span v-if="scope.row.ruleId === undefined">
            <el-date-picker
              v-model="scope.row.ruleStartTime"
              type="date"
              value-format="yyyy-MM-dd"
              placeholder="选择日期">
            </el-date-picker></span>
            <span v-else-if="scope.row.ruleId === tabClickIndex && tabClickLabel ==='缴费时间'">
              <el-date-picker
                v-model="scope.row.ruleStartTime"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="选择日期"
                @blur="inputBlur(scope.row)"></el-date-picker></span>
            <span v-else>{{ scope.row.ruleStartTime }}</span>
          </template>
        </el-table-column>
        <el-table-column label="到期时间" align="center">
          <template slot-scope="scope">
            <span v-if="scope.row.ruleId === undefined">
            <el-date-picker
              v-model="scope.row.ruleEndTime"
              type="date"
              value-format="yyyy-MM-dd"
              placeholder="选择日期">
            </el-date-picker></span>
            <span v-else-if="scope.row.ruleId === tabClickIndex && tabClickLabel ==='到期时间'">
              <el-date-picker
                v-model="scope.row.ruleEndTime"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="选择日期"
                @blur="inputBlur(scope.row)"></el-date-picker></span>
            <span v-else>{{ scope.row.ruleEndTime }}</span>
          </template>
        </el-table-column>
        <el-table-column label="缴费金额" align="center">
          <template slot-scope="scope">
            <span v-if="scope.row.ruleId === undefined">
              <el-input v-model="scope.row.pay" maxlength="30"></el-input></span>
            <span v-else-if="scope.row.ruleId === tabClickIndex && tabClickLabel ==='缴费金额'">
            <el-input v-model="scope.row.pay" placeholder="请输入缴费金额" @blur="inputBlur(scope.row)" maxlength="30"/>
            </span>
            <span v-else>{{ scope.row.pay }}</span>
          </template>
        </el-table-column>
        <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
          <template slot-scope="scope">
            <div
              v-if="scope.row.ruleId === undefined">
              <el-button
                size="mini"
                type="text"
                icon="el-icon-plus"
                @click="handleAddRule(scope.row)"
                v-hasPermi="['server:rule:add']"
              >新增
              </el-button>
            </div>
            <div v-else>
              <el-button
                size="mini"
                type="text"
                icon="el-icon-edit"
                @click="handleupdateRule(scope.row)"
                v-hasPermi="['server:rule:edit']"
              >修改
              </el-button>
              <el-button
                size="mini"
                type="text"
                icon="el-icon-delete"
                @click="handleDelet(scope.row)"
                v-hasPermi="['server:rule:remove']"
              >删除
              </el-button>
            </div>
          </template>
        </el-table-column>
      </el-table>
    </el-dialog>

  </div>
</template>


<script>

import {
  addRecord,
  delRecord,
  exportRecord,
  getRecord,
  listRecord,
  updateRecord,
  importTemplate
} from "../../../api/server/estates/payRecord"
import {getToken} from '@/utils/auth'
import {addRule} from "@/api/server/estates/rule";
import {delRule, listRule, updateRule, getRule} from "../../../api/server/estates/rule";
import {listUser} from "../../../api/system/user";

export default {
  name: 'payRecord',
  components: {},
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 缴费记录表格数据
      payRecordList: [],
      //企业下拉框
      compOptions:[],
      //企业用户信息
      userOptions:[],
      // 弹出层标题
      title: '',
      // 是否显示弹出层
      open: false,
      //是否显示缴费规则弹出层
      rule: false,
      // 状态字典
      statusOptions: [],
      //日期范围
      dateRange: [],
      //缴费规则
      ruleList: [],
      tabClickIndex: null, // 点击的单元格
      tabClickLabel: '', // 当前点击的列名
      //缴费类型字典
      typeOptions: [],
      //规则字典
      // ruleOptions: [],
      //修改状态
      updateRule: false,
      // 缴费记录导入参数
      upload: {
        // 是否显示弹出层（缴费记录导入）
        open: false,
        // 弹出层标题（缴费记录导入）
        title: '',
        // 是否禁用上传
        isUploading: false,
        // 是否更新已经存在的缴费记录数据
        updateSupport: 0,
        // 设置上传的请求头部
        headers: {Authorization: 'Bearer ' + getToken()},
        // 上传的地址
        url: process.env.VUE_APP_BASE_API + '/server/payRecord/importData'
      },
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        compName: undefined,
        ruleType: undefined,
        daterange: undefined
      },
      // 表单参数
      form: {

      },
      //列信息
      columns: [
        {key: 0, label: "序号", visible: true},
        {key: 1, label: "企业名称", visible: true},
        {key: 2, label: "应缴金额", visible: true},
        {key: 3, label: "缴费时间", visible: true},
        {key: 4, label: "未交金额", visible: true},
        {key: 5, label: "缴费类型", visible: true},
        {key: 6, label: "缴费状态", visible: true},
      ],
      queryForm: {
        compName: [{ pattern: /^[\u4E00-\u9FA5A-Za-z0-9]+$/, message: '不能为特殊字符', trigger: 'blur'}],
      },
      // 表单校验
      rules: {
        userPhone: [
          {
            required: true,
            pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
            message: '请输入正确的电话号码',
            trigger: 'blur'
          }
        ],
        compName: [
          {required: true, message: '企业名称不能为空', trigger: 'blur'}
        ],
        userName: [
          {required: true, message: '财务姓名不能为空', trigger: 'blur'}
        ],
        ruleType: [
          {required: true, message: '缴费类型不能为空', trigger: 'change'}
        ],
        pay: [
          {required: true, message: '应缴金额不能为空', trigger: 'blur'}
        ],
        payStatus: [
          {required: true, message: '缴费状态不能为空', trigger: 'change'}
        ],
      }
    }
  },
  created() {
    this.getList()
    this.getRuleList()
    this.getDicts('t_pay_status').then(response => {
      this.statusOptions = response.data
    })
    this.getDicts('t_rule_type').then(response => {
      this.typeOptions = response.data
    })
  },
  methods: {
    // 添加明细原因 row 当前行 column 当前列
    tabClick(row, column, cell, event) {
      switch (column.label) {
        case '规则名称':
          this.tabClickIndex = row.ruleId
          this.tabClickLabel = column.label
          break
        case '缴费类型':
          this.tabClickIndex = row.ruleId
          this.tabClickLabel = column.label
          break
        case '缴费金额':
          this.tabClickIndex = row.ruleId
          this.tabClickLabel = column.label
          break
        case '缴费时间':
          this.tabClickIndex = row.ruleId
          this.tabClickLabel = column.label
          break
        case '到期时间':
          this.tabClickIndex = row.ruleId
          this.tabClickLabel = column.label
          break
        default:
          return
      }
    },
    // 失去焦点初始化
    inputBlur(row, value, column) {
      const data = {
        "ruleId":row.ruleId,
        "ruleName":row.ruleName,
        "ruleType":row.ruleType,
        "ruleStartTime":row.ruleStartTime,
        "ruleEndTime":row.ruleEndTime,
        "pay":row.pay,
      }
    },

    /** 查询定时任务列表 */
    getList() {
      listRecord(this.addDateRange1(this.queryParams, this.dateRange)).then(response => {
        this.payRecordList = response.rows
        this.total = response.total
        this.loading = false
      })

    },
    getRuleList(){
      this.loading = true
      listRule().then(response => {
        this.ruleList = response.rows
        //this.total = response.total
        this.loading = false
      })
    },
    // 状态字典翻译
    statusFormat(row, column) {
      return this.selectDictLabel(this.statusOptions, row.payStatus)
    },
    typeFormat(row, column) {
      return this.selectDictLabel(this.typeOptions, row.ruleType)
    },
    // 取消按钮
    cancel() {
      this.open = false
      this.rule = false
      this.reset()
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1
      this.$refs['queryForm'].validate(valid => {
        if (valid) {
          this.getList()
        }
      })
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = []
      this.queryParams.params.beginTime = ''
      this.queryParams.params.endTime = ''
      this.resetForm('queryForm')
      this.handleQuery()
    },
    //表单重置
    reset() {
      this.form = {
        compName:null,
        compId:null,
        userName:null,
        userPhone:null,
        pay:null,
        payTime:null,
        payStatus:null,
        remark:null
      }
      this.resetForm('form')
      this.resetForm('ruleList')
    },

    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.payId)
      this.single = selection.length != 1
      this.multiple = !selection.length
    },
    /** 缴费规则按钮操作 */
    handleRule() {
      this.reset()
      this.getRuleList()
      this.rule = true
      this.title = '缴费规则管理'
    },
    /** 缴费规则删除 */
    handleDelet(index) {
      const ruleId = index.ruleId || this.ids
      if (ruleId.length === 0) {
        this.ruleList.splice(index, 1);
        this.getRuleList()
      } else {
        this.$confirm('是否确认删除缴费规则编号为"' + ruleId + '"的数据项?', '警告', {
          confirmButtonClass: "btn-custom-cancel",
          closeOnClickModal: false,
          type: "warning"
        }).then(function () {
          return delRule(ruleId)
        }).then(() => {
          this.getRuleList()
          this.msgSuccess('删除成功')
        })
      }
    },
    /** 新增缴费规则 */
    addRuleList() {
      this.ruleList.push({
        "ruleName": "",
        "ruleType": "",
        "ruleStartTime": "",
        "ruleEndTime": "",
        "pay": ""
      })
    },
    //修改缴费规则记录
    handleupdateRule(row){
      const data = {
        "ruleId":row.ruleId,
        "ruleName":row.ruleName,
        "ruleType":row.ruleType,
        "ruleStartTime":row.ruleStartTime,
        "ruleEndTime":row.ruleEndTime,
        "pay":row.pay,
      }
      updateRule(data).then(response => {
        this.msgSuccess('修改成功')
        this.tabClickIndex = null
        this.tabClickLabel = ''
        this.getRuleList()
      })
    },
    //获取财务人员下拉表
    serversClick(e) {
      listUser({userName: e}).then(res => {
        this.userOptions = res.rows
      })
    },
    //获取选择的财务人员信息并赋值给form表单中的数据
    changePhone(e) {
      for (let i in this.userOptions) {
        if (e === this.userOptions[i].userId) {
          this.form.userId = this.userOptions[i].userId
          this.form.userName = this.userOptions[i].userName
          this.form.userPhone = this.userOptions[i].phoneNumber
        }
      }
    },
    /** 提交缴费规则新增 */
    handleAddRule() {
      addRule(this.ruleList[this.ruleList.length - 1]).then(response => {
        this.msgSuccess('添加成功')
        this.getRuleList()
      })
    },
    //获取下拉框中的value值和label值
    selectGet(vId){
      let obj = {}
      obj = this.compOptions.find((item) => {
        return item.compId === vId;
      })
      this.form.compId = obj.compId
      this.form.compName = obj.compName
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset()
      getRecord().then(response => {
        this.compOptions = response.comps;
        this.open = true
        this.title = '添加缴费记录'
      })
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset()
      const payId = row.payId || this.payId
      getRecord(payId).then(response => {
        this.form = response.data
        this.compOptions = response.comps
        this.open = true
        this.title = '修改缴费记录'
      })
    },
    /** 提交按钮 */
    submitForm: function () {
      this.$refs['form'].validate(valid => {
        if (valid) {
          if (this.form.payId != null) {
            updateRecord(this.form).then(response => {
              this.msgSuccess('修改成功')
              this.open = false
              this.getList()
            })
          } else {
            addRecord(this.form).then(response => {
              this.msgSuccess('新增成功')
              this.open = false
              this.getList()
            })
          }
        }
      })

    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const payIds = row.payId || this.ids
      this.$confirm('是否确认删除该数据项?', '警告', {
        cancelButtonClass: 'btn-custom-cancel',
        closeOnClickModal: false,
        type: 'warning'
      }).then(function () {
        return delRecord(payIds);
      }).then(() => {
        this.getList()
        this.msgSuccess('删除成功')
      })
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams
      this.$confirm('是否确认导出所有预约表数据项?', '提示', {
        cancelButtonClass: 'btn-custom-cancel',
        closeOnClickModal: false,
        type: 'info'
      }).then(function () {
        return exportRecord(queryParams)
      }).then(response => {
        this.download(response.msg)
      })
    },
    /** 导入按钮 */
    handleImport() {
      this.reset()
      this.upload.title = '缴费记录'
      this.upload.open = true
    },
    /** 下载模板操作 */
    importTemplate() {
      importTemplate().then(response => {
        this.download(response.msg)
      })
    },
    // 文件上传中处理
    handleFileUploadProgress(event, file, fileList) {
      this.upload.isUploading = true
    },
    // 文件上传成功处理
    handleFileSuccess(response, file, fileList) {
      this.upload.open = false
      this.upload.isUploading = false
      this.$refs.upload.clearFiles()
      this.$alert(response.msg, '导入结果', {dangerouslyUseHTMLString: true})
      this.getList()
    },
    // 提交上传文件
    submitFileForm() {
      this.$refs['form'].validate(valid => {
        if(valid){
        this.$refs.upload.submit(this.form.ruleType)
        }
      })
    }

  }
}
</script>
